/*
 * Copyright (c) 2023-2299 深圳市阿毛科技有限公司 All rights reserved.
 *
 * https://www.lamyz.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */
package com.lam.common.utils.passwd;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.lam.common.config.AppBaseConfig;
import com.lam.common.exception.BaseException;
import com.lam.common.utils.StringUtils;

import cn.hutool.crypto.symmetric.AES;

/**
 */
public class PasswordManager {
	
    private static final Logger logger = LoggerFactory.getLogger(PasswordManager.class);


    public static String decryptPassword(String data) {
    	
    	if(StringUtils.isBlank(data)) {
    		return null;
    	}
        
        try {
        	AES aes = new AES(AppBaseConfig.me().getAuthPasswordSignKeyByte());
        	String decryptStr = aes.decryptStr(data);
            return decryptStr.substring(13);
        } catch (Exception e) {
            logger.error("AES解密异常:", e);
            throw new BaseException("AES解密错误", e);
        }
    }
}
